package com.mondo.financialwallet.presentation.ui.adapter;

import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mondo.financialwallet.R;
import com.mondo.financialwallet.presentation.model.ProductTradingTimeline;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

// TODO 中文
public class TradingTimelineAdapter extends BaseQuickAdapter<ProductTradingTimeline, BaseViewHolder> {

    public static RecyclerView.Adapter create(int type, String createDate, String addDate) {
        String title = type == 6 ? "提交清算申请" : "提交购买申请";
        String description = type == 6 ? "到账时间" : "起息时间";

        return new TradingTimelineAdapter(
                R.layout.item_product_trading_timeline,
                new ArrayList<>(Arrays.asList(
                        new ProductTradingTimeline(title, createDate),
                        new ProductTradingTimeline(description, addDate)
                ))
        );
    }

    private TradingTimelineAdapter(int layoutResId, @Nullable List<ProductTradingTimeline> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, ProductTradingTimeline item) {
        helper.setText(R.id.title_text, item.getTitle());
        helper.setText(R.id.date_text, item.getDate());
    }
}
